package cn.jimmie.learn.viewArt

import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentActivity
import cn.jimmie.learn.viewArt.fragment.*

/**
 * function :
 *
 * <p> Create Time:  2019年01月15日 17:08 </p>
 * <p> @author Jimmie.Qian  </p>
 */

class ShowActivity : FragmentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_show)

        val tag = intent.getIntExtra("tag", HEART_VIEW)

        val transaction = supportFragmentManager.beginTransaction()
        transaction.replace(R.id.fragment_content, getFragment(tag)).commitAllowingStateLoss()
    }

    private fun getFragment(tag: Int): Fragment {
        return when (tag) {
            HEART_VIEW -> HeartViewFragment()
            AUTO_LINE_VIEW -> AutoLineFragment()
            LRC_VIEW -> LrcFragment()
            OVERLAYER_VIEW -> OverLayerFragment()
            BALL_VIEW -> AssistBallFragment()
            CAPTCHA_VIEW -> CaptchaFragment()
            LOAD_VIEW -> LoadingFragment()
            ROUND_IMAGE -> RoundImageFragment()
            XFERMODE_VIEW -> XferModeFragment()
            GAME_VIEW -> GameFragment()
            BUTTERFLY_VIEW -> ButterflyFragment()
            LAYOUT_VIEW -> LayoutFragment()
            REFRESH_VIEW -> RefreshViewFragment()
            else -> HeartViewFragment()
        }
    }

    companion object {
        const val HEART_VIEW = 1
        const val AUTO_LINE_VIEW = 2
        const val LRC_VIEW = 3
        const val OVERLAYER_VIEW = 4
        const val BALL_VIEW = 5
        const val CAPTCHA_VIEW = 6
        const val LOAD_VIEW = 7
        const val ROUND_IMAGE = 8
        const val XFERMODE_VIEW = 9
        const val GAME_VIEW = 10
        const val BUTTERFLY_VIEW = 11
        const val LAYOUT_VIEW = 12
        const val REFRESH_VIEW = 13
    }
}